package com.bsj.pay.controller.admin;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import com.bsj.pay.model.LogBean;
import com.bsj.pay.service.LogService;
import com.bsj.pay.util.ResultUtil;
import com.github.pagehelper.PageInfo;

@Controller("adminLogController")
@RequestMapping("/admin/log")
public class LogController {
	@Autowired
	private LogService logService;
	
	@ResponseBody
	@RequestMapping(value = "/list.html")
	public Map list(HttpServletRequest req, HttpServletResponse res,int page,int limit,LogBean log) 
	{
		LogBean queryModel=new LogBean();
		if(!StringUtils.isEmpty(log.getUser_name()))queryModel.setUser_name(log.getUser_name());
		if(!StringUtils.isEmpty(log.getIp()))queryModel.setIp(log.getIp());
		PageInfo<LogBean> pageInfo=logService.pageList(queryModel, page, limit);
		return ResultUtil.getQuerySuccessResult(pageInfo);
	}
	
	@RequestMapping("/listPage.html")
	public ModelAndView listPage(HttpServletRequest request,HttpServletResponse response,ModelAndView mav)
	{
		mav.setViewName("admin/log/list");
		return mav;
	}
}
